package cn.bdqn.service.impl;

import cn.bdqn.dto.Dto;
import cn.bdqn.mapper.ItripHotelOrderMapper;
import cn.bdqn.mapper.ItripHotelRoomMapper;
import cn.bdqn.mapper.ItripOrderLinkUserMapper;
import cn.bdqn.pojo.ItripHotelOrder;
import cn.bdqn.pojo.ItripHotelRoom;
import cn.bdqn.pojo.ItripOrderLinkUser;
import cn.bdqn.pojo.ItripUserLinkUser;
import cn.bdqn.service.ItripOrderMessageService;
import cn.bdqn.vo.ItripOrderVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ItripOrderMessageImpl implements ItripOrderMessageService {
    @Resource
    private ItripHotelRoomMapper itripHotelRoomMapper;
    @Resource
    private ItripHotelOrderMapper itripHotelOrderMapper;

    @Resource
    private ItripOrderLinkUserMapper itripOrderLinkUserMapper;
    @Override
    public Dto insertOrderMessage(ItripHotelOrder itripHotelOrder) {
        Dto dto=new Dto();
        if(itripHotelOrderMapper.insertSelective(itripHotelOrder)>0){
            dto.setCode("0");
            dto.setMsg("插入成功");
            Map map=new HashMap<>();
            map.put("id", itripHotelOrder.getId().toString());
            map.put("orderNo", itripHotelOrder.getOrderNo());
            dto.setData(map);
            return dto;
        }
        dto.setCode("10001");
        dto.setMsg("插入信息失败");
        return dto;
    }

    //计算总价格
    @Override
    public BigDecimal selectrRoomMoney(Integer count, Long roomId) {
        ItripHotelRoom itripHotelRoom=itripHotelRoomMapper.selectByPrimaryKey(roomId);
        BigDecimal count1=new BigDecimal(count);
        return itripHotelRoom.getRoomPrice().multiply(count1);
    }


    //添加订单联系人信息
    public boolean insertOrderLinkUser(ItripOrderLinkUser itripOrderLinkUser){
        int i=itripOrderLinkUserMapper.insertSelective(itripOrderLinkUser);
        if(i>0){
            return true;
        }
        return false;
    }

}
